package com.itita.ww2.handler.requesthandler.account;

import java.sql.SQLException;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.itita.ww2.core.MessageHandler;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.enums.WW2ExceptionCode;
import com.itita.ww2.game.user.UserService;
import com.itita.ww2.utils.channel.ChannelUtil;
import com.itita.ww2.utils.handler.IRequestOper;

/**
 * 找回密码
 * @author NorthLan
 *
 */
public class RetrieveAccount implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		String token = params.getUtfString("token");
		int channel = params.getInt("channel");
		// 通过token找回帐号信息,而后找回帐号本体
		String channelId = ChannelUtil.getChannelId(channel, token);
		// 
		if (channelId == null) {
			throw new WW2Exception(WW2ExceptionCode.CHANNEL_VALIED_FAILURE);
		}
		// 
		ISFSObject backObj = UserService.getInstance().getBoundAccount(channelId);
		MessageHandler.getInstance().sendMsg(requestCMD, backObj, user, null, true);
		return true;
	}

}
